package com.chang.multithread;

import lombok.extern.slf4j.Slf4j;


import java.util.concurrent.TimeUnit;

@Slf4j
public class Interrupt {
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            log.debug("普通线程开始睡眠！");
            try {
                TimeUnit.SECONDS.sleep(5);//wait join
              } catch (InterruptedException e) {  //线程被中断以异常的形式出现，被中断标记为false
              e.printStackTrace(); }
        },"t1");

        t1.start();
        try {
            TimeUnit.SECONDS.sleep(1);
          } catch (InterruptedException e) {
          e.printStackTrace(); }
        log.debug("主线程打断普通线程");
        t1.interrupt();
        log.debug("打断标记：{}",t1.isInterrupted());


    }
}
